package com.c5p1ng.core.generator;

import com.c5p1ng.core.generator.base.GenericGenerator;
import com.c5p1ng.core.util.RandomUtil;
import com.c5p1ng.core.util.StrUtil;

/**
 * 手机号生成器
 *
 * @author c5p1ng
 */
public class ChineseMobileNumberGenerator extends GenericGenerator {
    private static final int[] MOBILE_PREFIX = new int[]{133, 153, 177, 180, 181, 189, 134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 178, 182, 183, 184, 187, 188, 130, 131, 132, 155, 156, 176, 185, 186, 145, 147, 170};
    private static ChineseMobileNumberGenerator instance = new ChineseMobileNumberGenerator();

    private ChineseMobileNumberGenerator() {
    }

    public static ChineseMobileNumberGenerator getInstance() {
        return instance;
    }

    public String generate() {
        return genMobilePre() + StrUtil.leftPad("" + RandomUtil.randomInt(0, 100000000), 8, "0");
    }

    public String generateFake() {
        return "19" + StrUtil.leftPad("" + RandomUtil.randomInt(0, 1000000000), 9, "0");
    }

    private static String genMobilePre() {
        return "" + MOBILE_PREFIX[RandomUtil.randomInt(0, MOBILE_PREFIX.length)];
    }
}
